﻿//===============================================================================
// La Pomme d'Or Krystal Application
// Windows Presentation Foundation Composite Application 
//===============================================================================
// Copyright (c) Jérôme Piquot.  All rights reserved.
// THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY
// OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT
// LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
// FITNESS FOR A PARTICULAR PURPOSE.
//===============================================================================
// The example companies, organizations, products, domain names,
// e-mail addresses, logos, people, places, and events depicted
// herein are fictitious.  No association with any real company,
// organization, product, domain name, email address, logo, person,
// places, or events is intended or should be inferred.
//===============================================================================

using System;
using System.ServiceModel;
using System.Collections;
using System.Collections.Generic;

namespace PJ.Data.WCF
{
    /// <summary>
    /// <see cref="IObjectData">Object data</see> persistence provider interface
    /// </summary>
    /// <typeparam name="TIObjectData"><see cref="IObjectData">Object data</see> type</typeparam>
    [ServiceContract]
    public interface IObjectWCFProvider<TIObjectData>
        where TIObjectData : IObjectData
    {
        /// <summary>
        /// Gets the data object from the data source
        /// </summary>
        /// <param name="sessionId">User session id</param>
        /// <param name="globalId">Object global id</param>
        /// <param name="mode">Fetch mode</param>
        /// <returns>The data object</returns>
        /// <exception cref="ArgumentNullException"><paramref name="globalId"/> is <see langref="null"/> or empty</exception>
        /// <exception cref="DataNotFoundException">If the object with the specified GlobalId is not found and fetch mode is not Find</exception>
        [OperationContract]
        TIObjectData GetData(string sessionId, string globalId, int mode);

        /// <summary>
        /// Gets a list of data objects from the data source
        /// </summary>
        /// <param name="sessionId">User session id</param>
        /// <param name="globalIds">Object global id list</param>
        /// <param name="mode">Fetch mode</param>
        /// <returns>The data object list</returns>
        /// <exception cref="ArgumentNullException"><paramref name="globalIds"/> is <see langref="null"/> or empty and fetch mode is not Find</exception>
        [OperationContract]
        List<TIObjectData> GetList(string sessionId, string[] globalIds, int mode);

        /// <summary>
        /// Persists the data object in the data source
        /// </summary>
        /// <param name="sessionId">User session id</param>
        /// <param name="data">Object to persist</param>
        /// <exception cref="ArgumentNullException"><paramref name="data"/> is <see langref="null"/></exception>
        [OperationContract]
        void Persist(string sessionId, TIObjectData data);

        /// <summary>
        /// Persists the data object in the data source and reloads it.
        /// </summary>
        /// <param name="sessionId">User session id</param>
        /// <param name="data">Object to persist</param>
        /// <returns>persisted data</returns>
        /// <exception cref="ArgumentNullException"><paramref name="data"/> is <see langref="null"/></exception>
        [OperationContract]
        TIObjectData PersistAndGet(string sessionId, TIObjectData data);


        /// <summary>
        /// Checks if the data object exists in the data source
        /// </summary>
        /// <param name="sessionId">User session id</param>
        /// <param name="globalId">Object global id</param>
        /// <returns>true if found in data source else false</returns>
        /// <exception cref="ArgumentNullException"><paramref name="globalId"/> is <see langref="null"/> or empty</exception>
        [OperationContract]
        bool Exist(string sessionId, string globalId);

        /// <summary>
        /// Removes the data object from the data source
        /// </summary>
        /// <param name="sessionId">User session id</param>
        /// <param name="globalId">Object global id</param>
        /// <exception cref="ArgumentNullException"><paramref name="globalId"/> is <see langref="null"/> or empty</exception>
        /// <exception cref="DataNotFoundException">The object with the specified GlobalId is not found</exception>
        [OperationContract]
        void Delete(string sessionId, string globalId);


    }
}
